Add support for nested sub-WHERE clauses and update hook naming#49
Merged
Add support for nested sub-WHERE clauses and update hook naming#49
Conversation
Rahmon
reviewed
Dec 20, 2025
lucatume
requested changes
Dec 22, 2025
Contributor
lucatume
left a comment
There was a problem hiding this comment.
Two requests:
- Add a test to cover malformed sub-WHERE inputs where one or more keys are missing or the operator is not correct.
- The changelog mentions a but-fix, is there a test for this?
Co-authored-by: theAverageDev (Luca Tumedei) <luca@theaveragedev.com>
…t/sub-where-clauses
Member
Author
|
@lucatume this is ready for a second look when you can ! |
lucatume
requested changes
Jan 5, 2026
Contributor
lucatume
left a comment
There was a problem hiding this comment.
Remove the use of the uopz extension to replace it with the use of filters and actions. The uopz extension should be used as a lsat resort when all other options have been exhausted, and it's not the case here.
lucatume
approved these changes
Jan 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR introduces support for nested sub-WHERE clauses in query methods and standardizes hook naming to align with the StellarWP namespace. These changes enable more flexible and complex database queries while maintaining backward compatibility through semantic versioning.
Key Changes
Nested Sub-WHERE Clauses - Adds the ability to build complex queries with grouped conditions and custom operators (AND/OR) within the
paginate()andget_total_items()methods.Hook Naming Standardization - Renamed all hooks from
tec_common_*prefix tostellarwp_schema_*prefix for namespace consistency (breaking change, documented in CHANGELOG).Technical Details
Sub-WHERE Clause Implementation
The implementation extracts sub-where clause logic into a new private method
build_sub_wheres_from_args()that recursively builds grouped query conditions. This allows developers to construct queries like:Architecture Decision: The recursive approach allows for arbitrary nesting depth without code duplication. Each sub-where group is wrapped in parentheses and joined with its specified operator, maintaining SQL precedence rules.
Breaking Changes
Hook names have been changed to reflect the correct namespace:
tec_common_custom_table_query_pre_results→stellarwp_schema_custom_table_query_pre_resultstec_common_custom_table_query_post_results→stellarwp_schema_custom_table_query_post_resultstec_common_custom_table_query_results→stellarwp_schema_custom_table_query_resultstec_common_custom_table_query_where→stellarwp_schema_custom_table_query_whereMigration Path: Consumers using these hooks must update their code. The change is documented in CHANGELOG.md with clear before/after examples.
Documentation
Updated documentation includes:
Areas Requiring Review Attention